package cn.sumpu.app.guoguojie.biz.impl.intercept;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import cn.sumpu.app.guoguojie.domain.Member;
import cn.sumpu.app.guoguojie.domain.OnLineUserListener;
import cn.sumpu.app.guoguojie.util.Common;

public class Message implements HandlerInterceptor {

	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		String ruri = request.getRequestURI(); 
		if(!Common.empty(ruri) && ("/notify.htm".equals(ruri)//我家的通知
								 ||"/pmessage.htm".equals(ruri)//我家的信息
								 ||"/loveus.htm".equals(ruri)//喜欢我家的
								 ||"/mention.htm".equals(ruri)//提到我家的
								 ||"/talk.htm".equals(ruri)//我家发表的
								 ||"/getMyFamilyComment.htm".equals(ruri)//评论我家的
								 ||"/newForumDoing.htm".equals(ruri)//发帖
								 ||"/saveForumDoingAndReply.htm".equals(ruri)//保存回应
								 ||"/toOauth.htm".equals(ruri) //同步设置
								 ||"/saveDoingNew.htm".equals(ruri)//保存微博
								 ||"/addDoingComment.htm".equals(ruri) //添加评论
								 ||"/meComment.htm".equals(ruri) //评论框
								 ||"/sendMessage.htm".equals(ruri) //发送消息
								 ||"/loveDoing.htm".equals(ruri) //喜欢微博
								 ||"/createPictorial.htm".equals(ruri)//创建编辑画报
								 ||"/joinPicDialog.htm".equals(ruri)//加入画报弹出框
							)){
		    Member member = OnLineUserListener.getSessionMember(request);
			if(member == null){
				response.sendRedirect("sessionTimeout.htm");
				return false;
			}
		}
		return true;
	}

	@Override
	public void postHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
		
	}

	@Override
	public void afterCompletion(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
		
	}

}
